<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/5/23
 * Time: 13:33
 */
include_once 'class/Http.php';
$config= include('class/config.php');

//$redis = new \think\cache\driver\Redis($config['redis']);
//$db = new \think\Db($config['db']);
$http = new Http();
$genderList=[1,2];
$baseUrl="47.56.207.234/v3/novel/chapter?userId=7b4asem&novelId=";

$booklist = file_get_contents('data/bookList.csv');
$booklist = array_filter(explode("\r",$booklist));

foreach ($booklist as $num =>$book){
    $book = json_decode($book,true);
    $url = $baseUrl.$book['nId'];
    $list = $http::curlPost($url);
    $list = json_decode($list,true);
    echo $num.":".$book['name'].PHP_EOL;
    if($list['status'] == 0 && !empty($list['data']['vs'])){
        $dataList = $list['data']['vs'];
        foreach ($dataList as $chapter){
            $chapter['nId']=$book['nId'];
            file_put_contents("data/chapter.csv",json_encode($chapter,258).PHP_EOL,FILE_APPEND);
        }
    }
}



